

#include<ratio>
#include<iostream>
#include<chrono>
using namespace std;



template <typename V, typename R>
ostream& operator<<(ostream &s, const std::chrono::duration<V,R> &d) 
{
    s<< "[" << d.count() <<" of : " << R::num <<" / "
                                    << R::den<<"]";
    return s;
}
int main()
{
    typedef ratio<5,3> FiveThirds;
    cout<<FiveThirds::num<<"/"<<
    FiveThirds::den<<endl;

    typedef ratio<25,15> AlsoFiveThirds;
    cout <<AlsoFiveThirds::den<<"/"<<
    FiveThirds::den<<endl;


    ratio<42,42> one;
    cout<<one.num<<"/"<<one.den<<endl;

    ratio<0> zero;
    cout<<zero.num<<"/"<<zero.den<<endl;

    typedef ratio<7,-2> Neg;
    cout<<Neg::num<<"/"<<Neg::den<<endl;


    ratio_add<ratio<1,10>,ratio<1,10>> Ratioadds;
    cout<<Ratioadds.num<<"/"<<Ratioadds.den<<endl;

    ratio_equal<ratio<5,3>, ratio<25,15>> EqualValue;
    cout<<"EqualValue::value = "<<EqualValue.value<<std::endl;

    std::chrono::seconds d1(42);
    std::chrono::milliseconds d2(10);
    std::cout<<"d1- d2="<<(d1-d2).count()<<" SECOND MAX: "<<std::chrono::seconds::max().count()<<std::endl;//d1- d2=41990
    std::cout<<d1<<std::endl;
    std::cout<<d2<<std::endl;
//      [42 of : 1 / 1]
//      [10 of : 1 / 1000]

    std::chrono::seconds sec(55);
   // std::chrono::minutes m1 = sec;
    std::chrono::minutes m2 = 
        std::chrono::duration_cast<std::chrono::minutes>(sec);
    std::cout<<m2<<std::endl;//[0 of : 60 / 1]


    
    return 0;
}


/*

#include <iostream>
#include <algorithm>

bool cmp(int m, int n)
{
    return m > n;
}


// test auxiliary
int main()
{
    std::cout << "min(10,20)\t" << std::min(10, 20);
    std::cout << std::endl;
    std::cout << "min(10,20,cmp)\t" << std::min(10, 20, cmp);
    std::cout << std::endl;

    std::cout << "min({10,20})\t" << std::min({10, 20});
    std::cout << std::endl;
    std::cout << "min({10,20},cmp)\t" << std::min({10, 20}, cmp);
    std::cout << std::endl;
    std::cout << "max(10,20)\t" << std::max(10, 20);
    std::cout << std::endl;

    std::cout << "max(10,20,cmp)\t"<< std::max(10,20, cmp);
    std::cout << std::endl;
    std::cout << "max({10,20})\t" << std::max({10, 20});
    std::cout << std::endl;
    std::cout << "max({10,20},cmp)\t"<< std::max({10,20},cmp);
    std::cout << std::endl;
    std::cout << std::endl;
    return 0;
}

min(10,20)      10
min(10,20,cmp)  20
min({10,20})    10
min({10,20},cmp)        20
max(10,20)      20
max(10,20,cmp)  10
max({10,20})    20
max({10,20},30) 10



#include<iostream>
#include<functional>
using namespace std;

class Test
{
public:
    void TestFun(int x, int y) const{
        std::cout<<"Test FUN is called";
        std::cout<<"X = "<<x <<"    Y ="<<y;
    }
};


int main()
{

    std::function<void(const Test&,int,int)> testFunCallBack;
    testFunCallBack = &Test::TestFun;
    testFunCallBack(Test(), 100, 200);


    std::function<void(int,int)> f;
    f(22,66); //throws std::bad_function_call
    Note that performing a function call without having a target to call throws an exception of type
std::bad_function_call (see Section 4.3.1, page 43)
    return 0;
}

Test FUN is called
X = 100    Y =200









 namespace std
 {
    template <typename T, T val>
    struct integral_constant {
        static constexpr T value  = val;
        typedef T value_type;
        typedef integral_constant<T,v> type;
        constexpr operator value_type() {
            return value;
        }
    };

    typedef integral_constant<bool, true> true_type;
    typedef integral_constant<bool, false> false_type;
 } // namespace name


#include<iostream>
int main()
{
    std::cout<<"result is "<< (false?"test1":"test2");
    return 0;
}




#include <iostream>
#include <limits>
#include <string>
using namespace std;

int main()
{
    // using textual representantion for bool
    cout << boolalpha;
    // print maximun of integral types
    cout << "max(short):" << numeric_limits<short>::max() << endl;
    cout << "max(int):" << numeric_limits<int>::max() << endl;
    cout << "max(long):" << numeric_limits<long>::max() << endl;
    cout<<endl;

    //print maximum of floating-point types
    cout<<"max(float):      "
        <<numeric_limits<float>::max()<<endl;

    cout<<"max(double):      "
        <<numeric_limits<double>::max()<<endl;

    cout<<"max(long double):      "
        <<numeric_limits<long double>::max()<<endl;

    //Conforms to standards IEC 559 and IEEE 754
    //print whether char is signed
    cout <<"is signed char: "
         <<numeric_limits<char>::is_signed<<endl;
    cout <<"is is_iec559 char: "
         <<numeric_limits<char>::is_iec559<<endl;

    //Type has specialization for numeric limits
    cout<<"is specilized(string)"
        <<numeric_limits<string>::is_specialized <<endl;

    cout<<endl;
}

max(short):32767
max(int):2147483647
max(long):9223372036854775807

max(float):      3.40282e+38
max(double):      1.79769e+308
max(long double):      1.18973e+4932
is signed char: true
is is_iec559 char: false
is specilized(string)false
*/

/*#include<memory>
#include<utility>
#include<iostream>

using namespace std;

class A
{
public:
    A() {
        cout<<"Construct is called"<<endl;
    }
    ~A() {
        cout<<"Deconstruct is called"<<endl;
    }
};provide


int main()
{
    std::unique_ptr<A> up1(new A);
    std::unique_ptr<A> up2(new A);
    up2 = std::move(up1);
    return 0;
}*/
/*#include<iostream>
#include<utility>
#include<tuple>

using namespace std;
provideprovide
class Fooo{
public:
    Fooo(tuple<int , float>) {
        cout << "Fooo::Foo(tuple)....." << endl;
    }

    template <typename... Args>
    Fooo(Args... args) {
        cout << "Fooo::Fooo(args...)"<<endl;
    }
};

int main()
{
    //create tuple t1
    tuple<int , float> t1(1,22.33);

    //pass the tuple as a whole to the construct of Fooo
    pair<int , Fooo> t2(45,t1);
    pair<int, Fooo> t3(piecewise_construct, make_tuple(42),t1);
    return 0;
}
Fooo::Foo(tuple).....
Fooo::Fooo(args...)
*/
